import React, { JSX } from 'react';
import { Navigate } from 'react-router-dom';

interface PrivateRouteProps {
  element: JSX.Element;
}

const PrivateRoute: React.FC<PrivateRouteProps> = ({ element }) => {
  const token = localStorage.getItem('token');
  console.log("check token:"+token)
  if (!token) {
    return <Navigate to="/login" replace />;
  }

  //add role based check or any check before navigate
  return element;
};

export default PrivateRoute;
